<?php

// 首页
class weatherAction extends Action {

	 public function index()
    {
		
		if(isset($_GET['aid'])){
			$aid = intval($_GET['aid']);
		}else{
			$aid=0;
		}

		//获取站点名称
		if(!empty($_SESSION['area'])){
			$area = $_SESSION['area'];
		}else{
			$area = getAreaName($aid);
		}

		//获取顶部广告
		$m = M('advert');	  
		$map=array('status'=>1);
		//if($aid) $map['aid']=$aid;
		$advlist = $m->where($map)->limit(10)->select();

		$catid = intval($_GET['catid']);
		$catename = getCategoryName($catid);

		import('ORG.Util.Page');// 导入分页类
		$m = M('Businesses');
		$map = array('status'=>1);
		$map['recommend']=0;
		if($aid) $map['aid']=$aid;

		//普通商家列表
		$map['catid'] = 2;
		$bmxx = $m->where($map)->order('price desc, create_time desc')->limit(4)->select();
		//echo $m->getLastsql();
					
		$map['catid'] = 5;
		$jdbg = $m->where($map)->order('price desc, create_time desc')->limit(4)->select();

		$map['catid'] = 4;
		$xiuxian = $m->where($map)->order('price desc, create_time desc')->limit(4)->select();

		$map['catid'] = 3;
		$life = $m->where($map)->order('price desc, create_time desc')->limit(4)->select();

		//推荐商家列表
		$map['recommend']=1;
		unset($map['catid']);
		$r_list = $m->where($map)->order('price desc, create_time desc')->limit(8)->select();
		//echo $m->getLastSql();
		
		//最新信息
		$m = M('Info');
		$map = array('status'=>1);
		$news = $m->where($map)->order('create_time desc')->limit(12)->select();
		
		//最新信息, 招聘信息
		$map = array('catid'=>17);
		$zhaop = $m->where($map)->order('create_time desc')->limit(12)->select();
		//最新信息, 房屋信息
		$map = array('catid'=>21);
		$fangwu = $m->where($map)->order('create_time desc')->limit(12)->select();
		
		//最新信息, 供求信息
		$map = array('catid'=>22);
		$gongqiu = $m->where($map)->order('create_time desc')->limit(12)->select();
		
		//最新信息, 二手信息
		$map = array('catid'=>24);
		$ershou = $m->where($map)->order('create_time desc')->limit(12)->select();
		
		
		//获取站点名称
		if(!empty($_SESSION['webname']))
			$webname = $_SESSION['webname'];
		else 
			$webname = getWebname($aid);
		
		$this->assign('aid',$aid);
		$this->assign('area',$area);
		$this->assign('webname',$webname);
		$this->assign('advlist',$advlist);
		$this->assign('catid',$catid);
		$this->assign('catename',$catename);

		$this->assign('bmxx',$bmxx);
		$this->assign('jdbg',$jdbg);
		$this->assign('xiuxian',$xiuxian);
		$this->assign('life',$life);
		
		$this->assign('r_list',$r_list);
		
		$this->assign('news',$news);
		$this->assign('zhaop',$zhaop);
		$this->assign('fangwu',$fangwu);
		$this->assign('gongqiu',$gongqiu);
		$this->assign('ershou',$ershou);
		
		$this->display();
    }

}

